package cn.com.tarotframework.utils.exception;

import cn.com.tarotframework.utils.response.TarotCode;
import lombok.Getter;

import java.io.Serial;

/**
 * copyright (C), 2022, 塔罗牌基础架构
 * @program: tarot-config-spring-boot-starter
 * @description: 公共异常处理
 * @author: xincan
 * @date: 2022/05/20 16:44
 * @version: 0.0.1-SNAPSHOT
 */
@Getter
public class TarotBusinessException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = -1378767771291567339L;

    private int code;

    private String msg;


    public TarotBusinessException() {
        this(TarotCode.BUSINESS_EXCEPTION.code(), TarotCode.BUSINESS_EXCEPTION.message());
    }

    public TarotBusinessException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public TarotBusinessException(String msg) {
        this(TarotCode.BUSINESS_EXCEPTION.code(), msg);
    }

    public TarotBusinessException(TarotCode tarotCode) {
        this(tarotCode.code(), tarotCode.message());
        this.code = tarotCode.code();
        this.msg = tarotCode.message();
    }

    public TarotBusinessException(TarotCode tarotCode, String msg) {
        this(tarotCode.code(), msg);
        this.code = tarotCode.code();
        this.msg = msg;
    }

    public TarotBusinessException(TarotCode tarotCode, Throwable throwable) {
        super(tarotCode.message(), throwable);
        this.code = tarotCode.code();
        this.msg = tarotCode.message();
    }

    public TarotBusinessException(TarotCode tarotCode, String msg, Throwable throwable) {
        this(TarotCode.BUSINESS_EXCEPTION.code(), TarotCode.BUSINESS_EXCEPTION.message());
        this.code = tarotCode.code();
        this.msg = msg;
    }

    public TarotBusinessException(String msg, Throwable throwable) {
        this(TarotCode.BUSINESS_EXCEPTION.code(), TarotCode.BUSINESS_EXCEPTION.message());
        this.code = TarotCode.BUSINESS_EXCEPTION.code();
        this.msg = msg;
    }

}
